﻿
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-collapse" lay-accordion="">
                        <div class="layui-colla-item">
                            <!--搜索区域-->
                            <h2 class="layui-colla-title">筛选查询</h2>
                            <div class="layui-colla-content layui-show">
                                <div class="layui-card">
                                    <form class="layui-form" lay-filter="SearchForm" id="SearchForm" autocomplete="off">
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">耗时：</label>'
                                                <div class="layui-input-inline">
                                                    <input type="number" name='TakeUpTime' placeholder='耗时' class="layui-input" value="0">
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label"> 日志类型:</label>
                                                <div class="layui-input-inline">
                                                    <select class="layui-input" name='LogType' id='LogType'  lay-filter='LogType' >
                                                        <option value="0">请选择</option>
                                                        <option value="4">登录</option>
                                                        <option value="1">接口调用</option>
                                                        <option value="2">SQL执行</option>
                                                        <option value="3">页面加载</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">接口地址：</label>'
                                                <div class="layui-input-inline">
                                                    <input type="text" name='RequestPath' placeholder='接口地址' class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">开始日期:</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" class="layui-input" name='sCreatedOn' id="sCreatedOn" placeholder="yyyy-MM-dd">
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">结束日期:</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" class="layui-input" name='EndDate' id="EndDate" placeholder="yyyy-MM-dd">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label"></label>

                                                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="Search">搜索</button>
                                                <button class="layui-btn layui-btn-primary" id="Reset">重置</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-card">
                <div class="layui-card-body">
                    <script type="text/html" id="logTyTemp">
                        {{# if(d.LogType== 0) { }}
                        登录
                        {{# } else if(d.LogType== 1) { }}
                        接口调用
                        {{# } else if(d.LogType== 2) { }}
                        SQL执行
                        {{# } else if(d.LogType== 3) { }}
                        页面加载
                        {{# } }}
                    </script>
                    <div style="margin-top: 10px;" id="AutoTablediv">
                        <!-- 加载列表 -->

                        <table class="layui-hide" style="width:100%" id="ListTable" lay-filter="ListTable"></table>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div> 
 
<script src="/Scripts/common.js?v=4"></script>
<script>
    var form
    var table
    //接收table 列数组
    var colArry = [{ "field": "TakeUpTime", "title": "耗时", "align": "center", "hide": false }, { "field": "LogType", "title": "日志类型", "templet":"#logTyTemp" ,"align": "center", "hide": false }, { "field": "IPAddress", "title": "地址", "align": "center", "hide": false }, { "field": "RequestParams", "title": "参数", "align": "center", "hide": false }, { "field": "CreatedBy", "title": "调用人", "align": "center", "hide": true }, { "field": "RequestPath", "title": "接口地址", "align": "center", "hide": false }, { "field": "CreatedOn", "title": "调用时间", "align": "center", "hide": false }, { "field": "RecordStatus", "title": "状态", "align": "center", "hide": true }, { "field": "ID", "title": "主键", "align": "center", "hide": true }, { "field": "UserName", "title": "用户名", "align": "center", "hide": false }, { "field": "Method", "title": "方法名", "align": "center", "hide": false }]
    //日期控件id 数组
    var dateList = ["#sCreatedOn","#EndDate"]
    

    //获取列表地址
    var getUrl = "/SysOperationLog/GetList"
    

    layui.use(['laydate', 'table', 'form'], function () {
        var laydate = layui.laydate;
        var form = layui.form,
            table = layui.table

        form.render("select");
        //执行一个laydate实例
        for (var index = 0; index < dateList.length; index++) {
            laydate.render({
                elem: dateList[index] //指定元素
            });
        }
        //重置
        $(document).on('click', '#Reset', function () {
            $('#SearchForm')[0].reset();
            form.render(null, 'SearchForm');
            return false;
        });
        //查询
        form.on('submit(Search)', function (data) {

            debugger
            //执行重载
            table.reload(tableId, {
                page: {
                    curr: 1 //重新从第 1 页开始

                },
                where: data.field
            }, 'data');

            return false;

        });
        tableId = "ListTable";

        InitTable(colArry);

        function InitTable(arry) {

          
            //列表 初始化
            table.render({
                elem: '#' + tableId,
                url: getUrl,
                method: 'post',
                headers: setTableHeader(),
                contentType: "application/json",
                dataType: "json",
                cols: [
                    arry
                ],
                page: true,
                where: {
                    dt: new Date()
                },
                done: function (res, curr, count) {

                }
            });
        }


         
    });
   

</script>
